import type Respondent from "@/types/response/respondent";
import AxiosManager from "../axiosManager";
import ResUtil from "@/utils/resUtil";
let instance = AxiosManager.respondentAxios;
//修改被申请人的个人资料
async function updateRespondent(respondent:Respondent){
 let res=await instance.put("/respondent",respondent);
 return ResUtil.isSuccess(res);
}
async function changePhone(respondent){
    return ResUtil.getData(await instance.post("/respondent/change-phone",respondent))
}
async function getRespondentById(respondentId:number){
    let res=await instance.get("/respondent",{
        params:{respondentId}
    });
    if(ResUtil.isSuccess(res)){
        return ResUtil.getData<Respondent>(res);
    }
    return null;
}
async function getRespondentByPhone(phoneNum:string){
    let res=await instance.get("/respondent/phone",{
        params:{phoneNum}
    });
    return ResUtil.getData<Respondent>(res);
}
async function getAllRespondent(){
    let res=await instance.get("/respondents");
    return ResUtil.getData<Respondent[]>(res);
}
export {
    updateRespondent,
    getRespondentById,
    getRespondentByPhone,
    changePhone,
    getAllRespondent
}